package jxta.chat;

import java.util.ArrayList;
import java.util.List;

import jxta.chat.entities.AbstractMessage;
import jxta.chat.events.JxtaChatEvent;
import jxta.chat.events.JxtaChatListener;
import jxta.chat.util.Constants;
import net.jxta.endpoint.Message;
import net.jxta.peergroup.PeerGroup;
import net.jxta.pipe.PipeMsgEvent;
import net.jxta.pipe.PipeMsgListener;

public abstract class AbstractMessageHandler implements PipeMsgListener{

	private List<JxtaChatListener> listeners = new ArrayList<JxtaChatListener>();
	
	public void addListener(JxtaChatListener listener){
		listeners.add(listener);
	}
	
	protected void notifyListeners(JxtaChatEvent event){
		for (JxtaChatListener listener : listeners){
			listener.jxtaChatEvent(event);
		}
	}

	public abstract AbstractMessage handleMessage(Message msg, PeerGroup pg);
}
